package wqh.global;

import java.util.*;

/**
 * Created by devts on 2017/1/5.
 */
public class GlobalWaterDevice {

    private static final Map<String, Object> maps = Collections.synchronizedMap(new HashMap<String,Object>());

    public static synchronized void addDevice(String ipPort, Object value){
        maps.put(ipPort,value);
    }

    public static synchronized void removeDevice(String ipPort){
        maps.remove(ipPort);
    }

    public static synchronized void clear(){
        maps.clear();
    }

    public static synchronized  Map<String ,Object> getMaps(){
        return maps;
    }


    public static synchronized Object getData(String ipPort){
        if(!maps.isEmpty()){
            for(Map.Entry<String,Object> m : maps.entrySet()){
                if(m.getKey().equals(ipPort)) return m.getValue();
            }
        }
        return null;
    }

}
